<template>
    <div>
        <a-modal
            :title="currentRow.modalTitle+'抽选'"
            :visible="visible"
            :confirm-loading="confirmLoading"
            @ok="handleOk"
            @cancel="visible = false"
            :width="800"
            
        >
            <div class="automaticAssignmentConditions-modal-box-v">
                <table border bordercolor="#d9d9d9" style="width: 100%; margin-top: 15px;">
                    <tr>
                        <td class="title-left-v">回避区域</td>
                        <td colspan="5">
                            <compSelector
                                :key="compSelectorkey"
                                v-model="currentRow.hbqy" 
                                :defaultValue="currentRow.hbqy"
                                compType="Checkbox"
                                dictionaryType="观察员所属地市"
                            />
                            <!-- @selectHandleChange="selectHandleChangeOny('hbqy',currentRow.hbqy)" -->
                        </td>
                    </tr>
                    <tr>
                        <td class="title-left-v">专业特长</td>
                        <td colspan="5">
                            <compSelector
                                :key="compSelectorkey"
                                v-model="currentRow.zytc" 
                                :defaultValue="currentRow.zytc"
                                compType="Checkbox"
                                dictionaryType="药品生产专业特长"
                                separateAreas='zytc001002'
                                
                            />
                            <!-- @selectHandleChange="selectHandleChangeOny('zytc',currentRow.zytc)" -->
                        </td>
                    </tr>
                    <tr>
                        <td class="title-left-v">组长人数</td>
                        <td>
                            <a-input-number v-model:value="currentRow.fzzrs" :min="0" :precision="0" />
                        </td>
                        <td class="title-left-v">组员人数</td>
                        <td>
                            <a-input-number v-model:value="currentRow.fzyrs" :min="0" :precision="0" />
                        </td>
                        <td class="title-left-v">预备审评员人数</td>
                        <td>
                            <a-input-number v-model:value="currentRow.fybrs" :min="0" :precision="0" />
                        </td>
                    </tr>
                    <!-- <tr>
                        <td class="title-left-v">是否发送确认短信</td>
                        <td colspan="5">
                            <compSelector
                                :key="compSelectorkey"
                                v-model="currentRow.fsmszt" 
                                :defaultValue="currentRow.fsmszt"
                                compType="Radio"
                                :options="[{
                                    label:'是',
                                    value:'是',
                                },{
                                    label:'否',
                                    value:'否',
                                }]"
                            />
                        </td>
                    </tr>
                    <tr v-if="currentRow.fsmszt == '是'">
                        <td class="title-left-v">短信内容</td>
                        <td colspan="5">
                            <a-textarea 
                                v-model="currentRow.fdqrdxnr"
                                :autosize="{ minRows: 2, maxRows: 10000 }"
                                placeholder="请输入短信内容"
                            ></a-textarea>
                        </td>
                    </tr> -->
                </table>
            </div>
        </a-modal>
    </div>
</template>
<script>
import { commononeTouchHcyByAuto, ybmjhybmJcyXpByAuto, sqsxYwxxgetCxrySendDqrSmsNr, } from "./service/index";
import compSelector from '@/components/compSelector/compSelector'
export default {
    components:{
        compSelector,
    },
    props:{

    },
    data(){
        return{
            currentRow:{},
            visible:false,
            confirmLoading:false,
            compSelectorkey:null,
        }
    },
    watch:{

    },
    mounted(){
        
    },
    methods:{
        getData(row){
            this.currentRow = {
                ...row,
                fzzrs:row.fzzrs?row.fzzrs:0,
                fzyrs:row.fzyrs?row.fzyrs:0,
                fybrs:row.fybrs?row.fybrs:0,
                // fsmszt:'否',
            }
            this.compSelectorkey = Date.now()
            this.confirmLoading = false
            // sqsxYwxxgetCxrySendDqrSmsNr({sqsxid:row.sqsxid}).then(res=>{
            //     if(res.code == 200){
            //         this.currentRow.fdqrdxnr = res.result
            //         //console.log('获取到什么短信内容',res.result)
            //     }else{}
            // })
        },
        handleOk(){
            if(this.currentRow.fzzrs || this.currentRow.fzyrs || this.currentRow.fybrs){
                if(this.currentRow.fsmszt == '是' && !this.currentRow.fdqrdxnr){
                    this.$message.warning('请输入短信内容')
                    return
                }
                this.confirmLoading = true
                let data = {
                    ...this.currentRow,
                    hbqy:this.currentRow.hbqy && this.currentRow.hbqy.length?this.currentRow.hbqy.join(','):'',
                    zytc:this.currentRow.zytc && this.currentRow.zytc.length?this.currentRow.zytc.join(','):'',
                }
                if(this.currentRow.randomlyType == 'All'){
                    commononeTouchHcyByAuto(data).then(res=>{
                        if(res.code == 200){
                            this.$message.success(res.message)
                            this.$emit('AssignmentConditionsSuccess',this.currentRow)
                            this.visible = false
                        }else{
                            this.$message.warning(res.message)
                        }
                        this.confirmLoading = false
                    })
                }else{
                    ybmjhybmJcyXpByAuto(data).then(res=>{
                        if(res.code == 200){
                            this.$message.success(res.message)
                            this.$emit('AssignmentConditionsSuccess',this.currentRow)
                            this.visible = false
                        }else{
                            this.$message.warning(res.message)
                        }
                        this.confirmLoading = false
                    })
                }
            }else{
                this.$message.warning('请输入人数')
            }
            
        },
    }
}
</script>
<style lang="less">
.automaticAssignmentConditions-modal-box-v{
    td{
        padding: 5px;
        height: 30px;
    }
    .title-left-v{
        text-align: center;
        width: 217px;
        font-weight: 600;
        font-size: 16px;
        background-color:#e6f7ff;
        font-family: simHei;
        color: rgba(0, 0, 0, 0.85);
    }
}
</style>